<template>
	<view class="main-box">
		<view class="navigator-bar" :style="{'padding-top': safeTop + 'px'}">
			<image class="back-img" src="/static/backArrow2.png" @click="back()"></image>
			<text class="page-title">设置</text>
		</view>
		<view class="menu-list">
			<view class="menu-item" @click="jumpTo('userInfo')">
				<view class="menu-content">
					<image class="menu-img" src="/static/setInfo.png"></image>
					<text class="menu-text">个人资料</text>
				</view>
				<image class="menu-arrow" src="/static/enterArrowB.png"></image>
			</view>
			<view class="menu-item" @click="jumpTo('changePassword')">
				<view class="menu-content">
					<image class="menu-img" src="/static/setPassword.png"></image>
					<text class="menu-text">修改密码</text>
				</view>
				<image class="menu-arrow" src="/static/enterArrowB.png"></image>
			</view>
			<view class="menu-item" @click="jumpToShop()">
				<view class="menu-content">
					<image class="menu-img" src="/static/setShopCheck.png"></image>
					<text class="menu-text">商家认证</text>
				</view>
				<image class="menu-arrow" src="/static/enterArrowB.png"></image>
			</view>
			<view class="menu-item" @click="jumpTo('shopTransfer')" v-if="userInfo.shopId">
				<view class="menu-content">
					<image class="menu-img" src="/static/setMoveShop.png"></image>
					<text class="menu-text">店铺转交</text>
				</view>
				<image class="menu-arrow" src="/static/enterArrowB.png"></image>
			</view>
			<view class="menu-item" @click="jumpTo('about')">
				<view class="menu-content">
					<image class="menu-img" src="/static/setAbout.png"></image>
					<text class="menu-text">关于我们</text>
				</view>
				<image class="menu-arrow" src="/static/enterArrowB.png"></image>
			</view>
			<view class="menu-item" @click="jumpTo('feedback')">
				<view class="menu-content">
					<image class="menu-img" src="/static/setSuggest.png"></image>
					<text class="menu-text">建议反馈</text>
				</view>
				<image class="menu-arrow" src="/static/enterArrowB.png"></image>
			</view>
			<view class="menu-item" @click="loginOut()">
				<view class="menu-content">
					<image class="menu-img" src="/static/setQuit.png"></image>
					<text class="menu-text">退出登录</text>
				</view>
				<image class="menu-arrow" src="/static/enterArrowB.png"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				safeTop: 0,
				userInfo: {}
			};
		},
		onLoad() {
			this.safeTop = this.$safeTop;
			this.userInfo = this.$userInfo;
		},
		methods: {
			back() {
				uni.navigateBack();
			},
			jumpTo(path) {
				uni.navigateTo({
					url: `/pages/${path}`
				})
			},
			jumpToShop() {
				if (this.userInfo.shopId) {
					uni.navigateTo({
						url: `/pages/shopCheck?id=${this.userInfo.shopId}`
					})
				} else {
					uni.navigateTo({
						url: `/pages/shopCheck`
					})
				}
			},
			loginOut() {
				uni.removeStorage({
					key: 'token',
					success: function (res) {
						uni.redirectTo({
							url: '/pages/oneKeyLogin'
						});
						uni.showToast({
							title: '退出成功!',
							icon: 'success'
						})
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.main-box {
		width: 100vw;
		height: 100vh;
		background-color: white;
		display: flex;
		flex-direction: column;
		align-items: center;

		.navigator-bar {
			width: 100vw;
			height: 86rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;

			.back-img {
				width: 24rpx;
				height: 40rpx;
				margin-left: 42rpx;
				z-index: 999;
			}

			.page-title {
				font-size: 38rpx;
				font-weight: bold;
				color: #222222;
				position: absolute;
				width: 100vw;
				line-height: 38rpx;
				text-align: center;
			}
		}
		
		.menu-list {
			width: 100%;
			margin-top: 30rpx;
			
			.menu-item {
				width: calc(100% - 110rpx);
				height: 108rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 0 55rpx 0 55rpx;
				
				.menu-content {
					display: flex;
					align-items: center;
					
					.menu-img {
						width: 35rpx;
						height: 36rpx;
					}
					
					.menu-text {
						font-size: 31rpx;
						font-weight: 400;
						color: #222222;
						margin-left: 36rpx;
					}
				}
				
				.menu-arrow {
					width: 11rpx;
					height: 23rpx;
				}
			}
		}
	}
</style>
